using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WCFDicing.Client.DicingGameService;

namespace WCFDicing.Client
{
    public partial class MainForm : Form
    {
        public DicingTable table = new DicingTable();


        public MainForm()
        {
            InitializeComponent( );
            CreateRoomRequest( );
        }

        private void CreateRoomRequest()
        {
            DicingGameClient client = new DicingGameClient( );
            client.Open( );
            DicingRoomOption options = new DicingRoomOption( );
            options.ChanceCount = 3;
            options.EntryMoney = 50;
            options.MaximumBet = 100;
            options.MinimumBet = 10;
            options.MaximumPlayers = 8;
            int id = client.CreateRoom( "nowy", options, 0 );
            id = client.CreateRoom( "nowy2", options, 0 );
         
            BindingList<DicingRoom> rooms = client.GetRoomList( );

            DicingPlayer player1 = new DicingPlayer();
            player1.PlayerId = 1;
            player1.MoneyField = 1000;
            
            DicingPlayer player2 = new DicingPlayer();
            player2.PlayerId = 2;
            player2.MoneyField = 900;

            client.Join( player1, id );
            client.Join( player2, id );

            rooms = client.GetRoomList( );

            DicingTable tab = client.GetTable( player1.PlayerId, id );
            bool cos = client.Join( player1, id );
            

            DicingPlayer player3 = new DicingPlayer( );
            player3.PlayerId = 3;
            player3.MoneyField = 700;
            client.Join( player3, id );

            tab = client.GetTable( player1.PlayerId, id );

            client.LeaveRoom( player1.PlayerId, id );

            tab = client.GetTable( player2.PlayerId, id );

            client.Join( player1, id );

            tab = client.GetTable( player1.PlayerId, id );

            int ble = client.ActualPlayer( id );

            client.Begin( id, player2.PlayerId );

            tab = client.GetTable( player2.PlayerId, id );

            int actPlay = client.ActualPlayer( id );

            bool hoho = client.Bet( 100, actPlay, id );

            tab = client.GetTable( player2.PlayerId, id );

            actPlay = client.ActualPlayer( id );

            bool hh = client.Bet( 50, actPlay, id );

            tab = client.GetTable( player2.PlayerId, id );

            actPlay = client.ActualPlayer( id );

            bool hm = client.Bet( 40, actPlay, id );

            tab = client.GetTable( player2.PlayerId, id );

            actPlay = client.ActualPlayer( id );

            DicingAnimation anim = new DicingAnimation( );
            anim.Valicity = 10;
            anim.X = 3;
            anim.Y = 2;
            anim.Z = 4;

            tab = client.GetTable( player2.PlayerId, id );

            rooms = client.GetRoomList( );

            bool hhhh = client.Begin( id, actPlay );

            DicingResult result = client.StartSimulation( anim, actPlay, id );

            //MessageBox.Show( result.Dice1.ToString( ) );

            tab = client.GetTable( player2.PlayerId, id );

            result = client.StartSimulation( anim, actPlay, id );

            tab = client.GetTable( player2.PlayerId, id );

            actPlay = client.ActualPlayer( id );

            hhhh = client.Begin( id, actPlay );

            //bool cm = client.LeaveRoom( actPlay, id );

            tab = client.GetTable( player2.PlayerId, id );

            result = client.StartSimulation( anim, actPlay, id );

            tab = client.GetTable( player2.PlayerId, id );

            bool hhh = client.Begin( id, player2.PlayerId );

            tab = client.GetTable( player2.PlayerId, id );

            result = client.StartSimulation( anim, actPlay, id );

            tab = client.GetTable( player2.PlayerId, id );

            result = client.StartSimulation( anim, actPlay, id );

            tab = client.GetTable( player2.PlayerId, id );

            //client.LeaveRoom( player2.PlayerId, id );
            //tab = client.GetTable( player3.PlayerId, id );
            //client.LeaveRoom( player3.PlayerId, id );
            //tab = client.GetTable( player3.PlayerId, id );

            rooms = client.GetRoomList( );

            int i = 150;

            client.Close( );
        }

        private void ExecuteButton_Click( object sender, EventArgs e )
        {
            //TODO: Call proxy method
        }
    }
}